﻿/*
Copyright (c) 2010 Vratislav Cermak (vratacermak@gmail.com)
 
This file is part of TeachMe Project. See http://code.google.com/p/teach-me for more information.
 
TeachMe is an open source project. Using of TeachMe is free of charge.
It is distributed under GNU General Public License version 3 (GPLv3).
GPLv3 can be found at http://www.gnu.org/licenses/gpl.html.
 
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

using TeachMe.Application.Properties;

namespace TeachMe.Application.Forms.Options
{
    public partial class Entries : OptionsControl
    {
        public Entries()
        {
            InitializeComponent();

            cbNewEntryMode.Items.Add(new ComboBoxItem<NewEntryMode>(NewEntryMode.Interval, Resources.EntryDisplayInterval));
            cbNewEntryMode.Items.Add(new ComboBoxItem<NewEntryMode>(NewEntryMode.OnDemand, Resources.OnDemand));
            cbNewEntryMode.Items.Add(new ComboBoxItem<NewEntryMode>(NewEntryMode.Persistent, Resources.Persistent));

            cbEntryRevealMode.Items.Add(new ComboBoxItem<EntryRevealReason>(EntryRevealReason.Immediate, Resources.Immediate));
            cbEntryRevealMode.Items.Add(new ComboBoxItem<EntryRevealReason>(EntryRevealReason.Click, Resources.Click));
            cbEntryRevealMode.Items.Add(new ComboBoxItem<EntryRevealReason>(EntryRevealReason.Interval, Resources.EntryRevealInterval));
        }

        internal override void LoadOptions()
        {
            ComboBoxItem<NewEntryMode>.Select(cbNewEntryMode, UserSettings.NewEntryMode.Value);
            ComboBoxItem<EntryRevealReason>.Select(cbEntryRevealMode, UserSettings.EntryRevealReason.Value);
            tbDisplayedEntriesCount.Value = UserSettings.MaxEntriesNumber.Value;
            cbEntriesAlwaysOnTop.Checked = UserSettings.TopMostEntries.Value;
            seOptionsForDisplayedEntriesCount.Text = UserSettings.MaxEntriesNumbers.Value;
        }

        internal override void SaveOptions()
        {
            UserSettings.NewEntryMode.Value = ComboBoxItem<NewEntryMode>.GetSelection(cbNewEntryMode);
            UserSettings.EntryRevealReason.Value = ComboBoxItem<EntryRevealReason>.GetSelection(cbEntryRevealMode);
            UserSettings.MaxEntriesNumber.Value = tbDisplayedEntriesCount.Value;
            UserSettings.TopMostEntries.Value = cbEntriesAlwaysOnTop.Checked;
            UserSettings.MaxEntriesNumbers.Value = seOptionsForDisplayedEntriesCount.Text;
        }
    }
}
